<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>编码管理</title>
	<#include "./comm/meta-base.ftl" />
	<#include "./comm/meta-easyui.ftl" />
	<#include "./comm/meta-comm.ftl" />
</head>
<body>
 <div id="datagrid_toolbar">
    		 <form id="search_form" class="search-form" role="form"   method="post" >
            	<div class="row">
                      <div class="form-group col-sm-4">
                        <label class="col-sm-4 fm-label">标题</label>
                        <div class="col-sm-8 fm-control">
                            <input type="text" class="form-control" name="title" />
                        </div>
                      </div>
                      <div class="form-buttons col-sm-4 float-right"  >
                      	<a href="javascript:submitForm()" class="btn btn-sm  btn-blue">
                            <i class="btn-label fa  fa-search "></i>查 询</a>
                        
                        <a href="javascript:resetForm('search_form')" class="btn btn-sm btn-default  margin-left-10 ">
                            <i class="btn-label fa  fa-reply "></i>重 置</a>
                    </div>
                 </div>
            </form>
            
            <div class="buttons-preview" >
                <a class="btn btn-default  btn-sm" 
                	href="javascript:addMessage()"><i class="fa fa-plus"></i>新增公告</a>
                <a class="btn btn-primary btn-sm" 
                	href="javascript:modifyMessage()"><i class="fa fa-edit"></i>修改公告</a>
                <a class="btn btn-danger btn-sm" 
                	href="javascript:removeMessage()"><i class="fa fa-times"></i>删除公告</a>
            </div>
        </div>
    
        <table id="data_table" class="easyui-datagrid"  border="0"  pagination="true" pageSize='20'  rownumbers="true" fitColumns="true" fit="true"
	               data-options="
	                   url: '${basePath}/message/message-list-json',
	                   method: 'get',
	                   rownumbers: true,
	                   idField: 'id',
	                   singleSelect: true,
	                   toolbar:'#datagrid_toolbar'
	               ">
	           <thead>
	           <tr>
	                <th data-options="field:'title',width:width(0.1),formatter:formatTitle">标题</th>
	                <th data-options="field:'subhead',width:width(0.1)">副标题</th>
	                <th data-options="field:'status',width:width(0.1)">状态</th>
	                <th data-options="field:'createTime_name',width:width(0.1)">创建时间</th>
	                <th data-options="field:'messageId',width:width(0.1),formatter:formatOperate">操作</th>
	            </tr>
	           </thead>
	       </table>


</body>
</html>
<script type="text/javascript">

function formatOperate(value,row){
	var htm="";
	if(row.status=='Y71'){
		htm="<a href=\"javascript:changeMessage('"+row.messageId+"','Y72');\" class=\"btn btn-sm btn-danger\">撤销公告</a>";
	}else{
		htm="<a href=\"javascript:changeMessage('"+row.messageId+"','Y71');\" class=\"btn btn-sm btn-success\">发布公告</a>";
	}
	return htm;
}
function changeMessage(messageId,status){
	var url="${basePath}/message/message-change/"+messageId;
	$.post(url,{status:status},function(dt){
		$("#data_table").datagrid("reload");
	});

}

function formatTitle(value,row){
	var htm="<a href=\"javascript:showMessage('"+row.messageId+"','"+row.title+"')\">"+row.title+"</a>";
	return htm;
}

function showMessage(messageId,title){
	var url="${basePath}/message/message-show/"+messageId;
	MainTab.createTab(messageId,"公告:"+title,url);
}

function removeMessage(){
	var row = $('#data_table').datagrid('getSelected');
	if(null!=row){
		var url="${basePath}/message/message-remove/"+row.messageId;
		bootbox.confirm("你确定要删除"+row.title+"?", function (result) {
        	if (result) {
            	$.post(url,{},function(data){
					$("#data_table").datagrid("reload");
				});
         	}
        });
		
	}else{
		Notify('请选择要操作的编码', 'top-right', '5000', 'danger', 'fa-bolt', true);
	}
}


function addMessage(){
	var url="${basePath}/message/message-addin";
	MainTab.createTab("MESSAGEADD","新增公告",url);
}
function modifyMessage(){
	var row = $('#data_table').datagrid('getSelected');
	if(null!=row){
		var url="${basePath}/message/message-modifyin/"+row.messageId;
		MainTab.createTab("MESSAGEMODIFY","修改公告",url);
	}else{
		Notify('请选择要修改的公告', 'top-right', '5000', 'danger', 'fa-bolt', true);
	}
	
}
</script>


